package com.neudu.yiyang.controller;

import com.neudu.yiyang.commons.JSONReturn;
import com.neudu.yiyang.pojo.Menu;
import com.neudu.yiyang.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/yyzx")
public class MenuController {
    @Autowired
    private MenuService menuService;

    @PostMapping("/getmenus")
    public String getMenusByRoleId(@RequestBody Map<String, Object> params) {
        try {
            Integer roleid = (Integer) params.get("roleid");
            List<Menu> menus = menuService.getByroleid(roleid);
            return new JSONReturn().returnSuccess(menus);
        } catch (Exception e) {
            e.printStackTrace();
            return new JSONReturn().returnError(e.getMessage());
        }
    }
}